// pages/select/select.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    selectList: [], //选择列表
    factorId: null //选中的factorId
  },

  /**
   * 获取客户类型信息
   */
  getClientInfo: function() {
    let that = this;
    wx.request({
      url: 'https://www.xiaozheng8.com/service/factor/findAll',
      method: 'post',
      data: {},
      success: function(res) {
        console.log("----")
        console.log(res)
        that.setData({
          selectList: res.data.data
        })
      }
    })
  },
  submit: function() {
    let page = getCurrentPages();
    var that = this;

    let prevPage = page[page.length - 2];
    if (this.data.factorId == null) {
      wx.showModal({
        title: '提示',
        content: '请选择客户类型',
        showCancel: false
      })
    } else {
      prevPage.setData({
        clientType: that.data.name,
        factorId: that.data.factorId,
        factor: that.data.factor
      });
      var client = that.data.name;
      wx.setStorageSync("client", client);
      wx.setStorageSync("factorId", that.data.factorId);
      wx.navigateBack({

      })
    }

  },




  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.getClientInfo();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 是否选中
   */
  isCheck: function(e) {

    this.setData({
      factorId: e.currentTarget.dataset.factorid,
      name: e.currentTarget.dataset.name,
      factor: e.currentTarget.dataset.factor
    })
    wx.setStorageSync("factor", this.data.factor)
  },


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})